//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//

//
#ifndef Green_RegisterReserverGPGPU_H
#define Green_RegisterReserverGPGPU_H

#include <map>
#include <vector>

#include "RegisterReserver.h"

namespace Green {

  /*!
    \class RegisterReserverGPGPU
    \brief Class providing RISC-specific functionality for reserving registers.
  */
  class RegisterReserverGPGPU : public RegisterReserver
  {
  public:
    RegisterReserverGPGPU(); //!< Constructor
    SUBCLASS_DESTRUCTOR_DEFAULT(RegisterReserverGPGPU); //!< Destructor
    ASSIGNMENT_OPERATOR_ABSENT(RegisterReserverGPGPU);

    Object* Clone() const override { return new RegisterReserverGPGPU(*this); } //!< Return a cloned Object of the same type and same contents as the Object being cloned.
    const char* Type() const override { return "RegisterReserverGPGPU"; } //!< Return a string describing the actual type of the Object.
   protected:
    RegisterReserverGPGPU(const RegisterReserverGPGPU& rOther); //!< Copy constructor
    ERegReserveGroup GetReserveGroupForOperandType(const EOperandType oprType) const override; //!< Get the reservation group for the specified operand type.
    const std::vector<ERegReserveGroup>& GetReserveGroupsForRegisterType(const ERegisterType regType) const override; //!< Get the reservation groups for the specified register type.
    void GetRegisterIndexRange(const ERegisterType regType, ConstraintSet* pIndexConstr) const override; //!< Retrieve the range of valid indices for the specified register type.
    uint32 GetPhysicalRegisterIndex(const PhysicalRegister* pPhysReg, const ERegisterType regType) const override; //!< Get the register index used for register reservation purposes.
    uint64 GetUpperLimit(const ERegisterType regType, const uint32_t  &limit) const;
  private:
    std::map<const EOperandType, const ERegReserveGroup> mReserveGroupsByOprType;
    std::map<const ERegisterType, const std::vector<ERegReserveGroup>> mReserveGroupsByRegType;
  };

}

#endif
